<?php
/**
 * Created by PhpStorm.
 * User: jingshou
 * Date: 2017/9/17
 * Time: 23:57
 */

namespace app\mobile\model;

use think\Db;
use think\Model;
use think\Cookie;

class MessageModel extends Model
{
    protected $table = 'tp_leav';

    public function add($data)
    {
        Db::startTrans();
        try {
            $model = new self();
            $model->data($data);
            $model->created = time();
            if ($model->save() == 0) {
                return $model->getError();
            }
            Db::commit();
            return true;
        } catch (\Exception $e) {
            Db::rollback();
            return $e->getMessage();
        }
    }
}